package com.lazydong.apiforward.client.route;

import com.lazydong.apiforward.client.framework.PageContainer;
import com.lazydong.apiforward.client.gui.enums.PageEventEnum;
import com.lazydong.apiforward.gateway.filter.CustomGlobalFilter;
import org.springframework.cloud.gateway.route.Route;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;

public class LogFilter implements CustomGlobalFilter {
    @Override
    public void beforeRequest(ServerHttpRequest request, Route route) {
        PageContainer.sendEvent(PageEventEnum.LOG_SHOW, " 转发前: " + request.getURI());
        String address = route.getUri().toString() + request.getPath();
        PageContainer.sendEvent(PageEventEnum.LOG_SHOW, " 转发后: " + address + System.lineSeparator());
    }

    @Override
    public void afterResponse(ServerHttpResponse response) {

    }
}
